<template>
  <div class="manage-wrap">
    <div class="manage-box">
      <!--条件搜索 -->
      <a-card style="margin-bottom: 10px">
        <a-form layout="inline" :model="queryFormData">
          <a-form-item label="资源编码：">
            <a-input
              style="width: 200px"
              v-model:value="queryFormData.resourcebm"
            ></a-input>
          </a-form-item>
          <a-form-item label="资源名称：">
            <a-input
              style="width: 200px"
              v-model:value="queryFormData.resourcemc"
            ></a-input>
          </a-form-item>
          <a-form-item label="资源标签关键词：">
            <a-input
              style="width: 200px"
              v-model:value="queryFormData.keyword"
            ></a-input>
          </a-form-item>
          <a-form-item>
            <a-button type="primary" style="margin-right: 4px" @click="Search">
              搜索
            </a-button>
            <a-button @click="Reset('queryFormData')"> 重置 </a-button>
          </a-form-item>
        </a-form>
      </a-card>
      <!-- 表格 -->
      <a-card style="margin-bottom: 10px">
        <div style="margin-bottom: 10px">
          <a-button style="margin-right: 10px" @click="AddCatalog">
            新增</a-button
          >
        </div>
        <!-- :row-selection="rowSelection" -->
        <a-table
          :rowKey="(record) => record.id"
          :defaultExpandAllRows="true"
          :columns="columns"
          :data-source="DataList"
          :pagination="pagination"
          @change="handleTableChange"
        >
          <template #operation="{ record }">
            <a-space>
              <a-button size="small" type="link" @click="Rectify(record)"
                >编辑</a-button
              >
              <a-popconfirm
                title="确定删除这条数据吗？"
                ok-text="确认"
                cancel-text="取消"
                @confirm="onDel(record)"
              >
                <a-button size="small" type="link">删除</a-button>
              </a-popconfirm>
            </a-space>
          </template>
        </a-table>
      </a-card>
    </div>
    <!-- 新增 -->
    <div :class="['new-form-box', show ? 'md-show' : '']">
      <div class="title-box">
        添加资源
        <span @click="show = false">X</span>
      </div>
      <div class="content-box beauty-scroll">
        <a-form label-align="right" :model="FormData">
          <h4>资源属性</h4>
          <a-row>
            <a-col :span="12">
              <a-form-item
                label="资源名称："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-input v-model:value="FormData.resourcemc"></a-input>
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item
                label="资源提供方："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-select
                  v-model:value="FormData.deptid"
                  style="width: 100%"
                  @change="deptidChange"
                >
                  <a-select-option
                    :value="item.dictValue"
                    v-for="item in ZytgList"
                    :key="item.dictValue"
                    >{{ item.dictLabel }}</a-select-option
                  >
                </a-select>
              </a-form-item>
            </a-col>
          </a-row>
          <a-row>
            <a-col :span="12">
              <a-form-item
                label="资源目录："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-tree-select
                  v-model:value="FormData.configrationid"
                  tree-data-simple-mode
                  show-search
                  :dropdown-style="{
                    height: '300px',
                    overflow: 'auto',
                  }"
                  placeholder="请输入查询关键词"
                  :tree-data="catalogTree"
                  @change="treeChange"
                >
                </a-tree-select>
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item
                label="资源编码："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-input v-model:value="FormData.resourcebm" disabled></a-input>
              </a-form-item>
            </a-col>
          </a-row>
          <a-row>
            <a-col :span="12">
              <a-form-item
                label="资源标签关键词："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-input v-model:value="FormData.keyword"></a-input>
              </a-form-item>
            </a-col>
          </a-row>
          <h4>资源来源</h4>
          <a-row>
            <a-col :span="12">
              <a-form-item
                label="来源名称："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-input v-model:value="FormData.resourcefl"></a-input>
              </a-form-item>
            </a-col>
          </a-row>
          <h4>资源分类</h4>
          <a-row>
            <a-col :span="12">
              <a-form-item
                label="行政区划："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-tree-select
                  v-model:value="FormData.xzqh"
                  tree-data-simple-mode
                  show-search
                  :dropdown-style="{
                    height: '200px',
                    overflow: 'auto',
                  }"
                  placeholder="请输入查询关键词"
                  :tree-data="administrativeTree"
                  @change="administrativeChange"
                ></a-tree-select>
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item
                label="服务类型："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-select style="width: 100%" v-model:value="FormData.fwlx">
                  <a-select-option
                    :value="item.dictValue"
                    v-for="item in FwlxList"
                    :key="item.dictValue"
                    >{{ item.dictLabel }}</a-select-option
                  >
                </a-select>
              </a-form-item>
            </a-col>
          </a-row>
          <a-row>
            <a-col :span="12">
              <a-form-item
                label="坐标系种类："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-select style="width: 100%" v-model:value="FormData.zbx">
                  <a-select-option
                    :value="item.dictValue"
                    v-for="item in ZbxList"
                    :key="item.dictValue"
                    >{{ item.dictLabel }}</a-select-option
                  >
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item
                label="比例尺："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-select style="width: 100%" v-model:value="FormData.bl">
                  <a-select-option
                    :value="item.dictValue"
                    v-for="item in BlList"
                    :key="item.dictValue"
                    >{{ item.dictLabel }}</a-select-option
                  >
                </a-select>
              </a-form-item>
            </a-col>
          </a-row>
          <a-row>
            <a-col :span="12">
              <a-form-item
                label="分辨率："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-select style="width: 100%" v-model:value="FormData.fbl">
                  <a-select-option
                    :value="item.dictValue"
                    v-for="item in FblList"
                    :key="item.dictValue"
                    >{{ item.dictLabel }}</a-select-option
                  >
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item
                label="原始服务地址："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-input v-model:value="FormData.fwdz"></a-input>
              </a-form-item>
            </a-col>
          </a-row>
          <a-row>
            <a-col :span="12">
              <a-form-item
                label="注册时间："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-date-picker
                  style="width: 100%"
                  @change="DateChange"
                  placeholder="选择时间"
                >
                </a-date-picker>
              </a-form-item>
            </a-col>
          </a-row>
          <h4>资源共享</h4>
          <a-row>
            <a-col :span="12">
              <a-form-item
                label="共享类型："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-select
                  style="width: 100%"
                  v-model:value="FormData.sharetype"
                >
                  <a-select-option
                    :value="item.dictValue"
                    v-for="item in GxlxList"
                    :key="item.dictValue"
                    >{{ item.dictLabel }}</a-select-option
                  >
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item
                label="共享范围："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-select v-model:value="FormData.sharescope">
                  <a-select-option
                    :value="item.dictValue"
                    v-for="item in GxfwList"
                    :key="item.dictValue"
                    >{{ item.dictLabel }}</a-select-option
                  >
                </a-select>
              </a-form-item>
            </a-col>
          </a-row>
          <a-row>
            <a-col :span="12">
              <a-form-item
                label="更新频率："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-select style="width: 100%" v-model:value="FormData.gxzq">
                  <a-select-option
                    :value="item.dictValue"
                    v-for="item in GxzqList"
                    :key="item.dictValue"
                    >{{ item.dictLabel }}</a-select-option
                  >
                </a-select>
              </a-form-item>
            </a-col>
          </a-row>
        </a-form>
      </div>
      <div class="footer-box">
        <a-button style="margin-right: 10px" type="primary" @click="send"
          >确认</a-button
        >
        <a-button @click="quxaio('show')"> 取消</a-button>
      </div>
    </div>
    <!-- 编辑 -->
    <div :class="['new-form-box', showEdit ? 'md-show' : '']">
      <div class="title-box">
        添加资源
        <span @click="showEdit = false">X</span>
      </div>
      <div class="content-box">
        <a-form
          label-align="right"
          :model="FormData"
          :wrapper-col="{ span: 12 }"
          :label-col="{ span: 4 }"
        >
          <a-row>
            <a-col :span="12">
              <a-form-item
                label="资源名称："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-input v-model:value="EditObj.resourcemc"></a-input>
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <!-- <a-form-item
                label="资源对象："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-input
                  disabled
                  v-model:value="EditObj.resourcesjdx"
                ></a-input>
              </a-form-item> -->
              <a-form-item
                label="资源编码："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-input disabled v-model:value="EditObj.resourcebm"></a-input>
              </a-form-item>
            </a-col>
          </a-row>
          <a-row>
            <a-col :span="12"
              ><a-form-item
                label="资源来源名称："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-input v-model:value="EditObj.resourcefl"></a-input>
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item
                label="资源目录："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-tree-select
                  v-model:value="EditObj.configrationid"
                  tree-data-simple-mode
                  show-search
                  :dropdown-style="{
                    height: '300px',
                    overflow: 'auto',
                  }"
                  placeholder="请输入查询关键词"
                  :tree-data="catalogTree"
                  @change="treeChange"
                >
                </a-tree-select> </a-form-item
            ></a-col>
          </a-row>
          <a-row>
            <a-col :span="12">
              <a-form-item
                label="所属区划："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-tree-select
                  v-model:value="EditObj.xzqh"
                  tree-data-simple-mode
                  show-search
                  style="width: 100%"
                  :dropdown-style="{
                    height: '200px',
                    overflow: 'auto',
                  }"
                  placeholder="请输入查询关键词"
                  :tree-data="administrativeTree"
                  @change="administrativeChange"
                ></a-tree-select> </a-form-item
            ></a-col>
            <a-col :span="12">
              <a-form-item
                label="服务类型："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-select style="width: 100%" v-model:value="EditObj.fwlx">
                  <a-select-option
                    :value="item.dictValue"
                    v-for="item in FwlxList"
                    :key="item.dictValue"
                    >{{ item.dictLabel }}</a-select-option
                  ></a-select
                >
              </a-form-item></a-col
            >
          </a-row>
          <a-row>
            <a-col :span="12">
              <a-form-item
                label="服务地址："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-input v-model:value="EditObj.fwdz"></a-input> </a-form-item
            ></a-col>
            <a-col :span="12">
              <a-form-item
                label="坐标系："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-select style="width: 100%" v-model:value="EditObj.zbx">
                  <a-select-option
                    :value="item.dictValue"
                    v-for="item in ZbxList"
                    :key="item.dictValue"
                    >{{ item.dictLabel }}</a-select-option
                  >
                </a-select>
              </a-form-item></a-col
            >
          </a-row>
          <a-row>
            <a-col :span="12">
              <a-form-item
                label="比例尺："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-select style="width: 100%" v-model:value="EditObj.bl">
                  <a-select-option
                    :value="item.dictValue"
                    v-for="item in BlList"
                    :key="item.dictValue"
                    >{{ item.dictLabel }}</a-select-option
                  >
                </a-select>
              </a-form-item></a-col
            >
            <a-col :span="12">
              <a-form-item
                label="分辨率："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-select style="width: 100%" v-model:value="EditObj.fbl">
                  <a-select-option
                    :value="item.dictValue"
                    v-for="item in FblList"
                    :key="item.dictValue"
                    >{{ item.dictLabel }}</a-select-option
                  >
                </a-select>
              </a-form-item>
            </a-col>
          </a-row>
          <a-row>
            <a-col :span="12">
              <a-form-item
                label="注册时间："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-date-picker
                  style="width: 100%"
                  v-model:value="EditObj.regdate"
                  format="YYYY-MM-DD"
                  @change="editDateChange"
                  placeholder="选择时间"
                >
                </a-date-picker> </a-form-item
            ></a-col>
            <a-col :span="12">
              <a-form-item
                label="资源提供方："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-select style="width: 100%" v-model:value="EditObj.deptid">
                  <a-select-option
                    :value="item.dictValue"
                    v-for="item in ZytgList"
                    :key="item.dictValue"
                    >{{ item.dictLabel }}</a-select-option
                  >
                </a-select>
              </a-form-item>
              <!-- <a-form-item
                label="空间范围："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-input v-model:value="EditObj.kjfw"></a-input>
              </a-form-item> -->
            </a-col>
          </a-row>
          <a-row>
            <a-col :span="12">
              <a-form-item
                label="资源数据量："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-input
                  disabled
                  v-model:value="EditObj.datatotalnum"
                ></a-input>
              </a-form-item>
              <!-- <a-form-item
                label="获取时间："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-input v-model:value="EditObj.kqsj"></a-input>
              </a-form-item> -->
            </a-col>
            <a-col :span="12">
              <a-form-item
                label="更新周期："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-select style="width: 100%" v-model:value="EditObj.gxzq">
                  <a-select-option
                    :value="item.dictValue"
                    v-for="item in GxzqList"
                    :key="item.dictValue"
                    >{{ item.dictLabel }}</a-select-option
                  >
                </a-select>
              </a-form-item></a-col
            >
          </a-row>
          <a-row>
            <a-col :span="12">
              <a-form-item
                label="资源标签："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-input
                  v-model:value="EditObj.keyword"
                ></a-input> </a-form-item
            ></a-col>
            <a-col :span="12"> </a-col>
          </a-row>
          <a-row>
            <a-col :span="12"> </a-col>
            <a-col :span="12">
              <!-- <a-form-item
                label="访问次数："
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
              >
                <a-input disabled v-model:value="EditObj.visitcount"></a-input>
              </a-form-item> -->
            </a-col>
          </a-row>
        </a-form>
      </div>
      <div class="footer-box">
        <a-button
          style="margin-right: 10px"
          type="primary"
          @click="sendEdit(EditObj)"
          >确认</a-button
        >
        <a-button @click="showEdit = false"> 取消</a-button>
      </div>
    </div>
  </div>
</template>
<script>
import * as API from "@/api/data-object";
import { buildtree, isLeaf } from "../../utils";
import { message } from "ant-design-vue";
const columns = [
  {
    title: "资源名称",
    dataIndex: "resourcemc",
    key: "resourcemc",
  },
  {
    title: "资源来源名称",
    dataIndex: "resourcefl",
    key: "resourcefl",
  },
  {
    title: "资源目录",
    dataIndex: "catalogName",
    key: "catalogName",
  },
  {
    title: "资源提供方",
    dataIndex: "deptname",
    key: "deptname",
  },
  {
    title: "服务类型",
    dataIndex: "fwlxName",
    key: "fwlxName",
  },
  {
    title: "比例值",
    dataIndex: "blName",
    key: "blName",
  },
  {
    title: "坐标系",
    dataIndex: "zbxName",
    key: "zbxName",
  },
  {
    title: "注册人姓名",
    dataIndex: "username",
    key: "username",
  },
  {
    title: "注册时间",
    dataIndex: "publishdate",
    key: "publishdate",
  },
  {
    title: "操作",
    key: "operation",
    align: "center",
    slots: { customRender: "operation" },
  },
];
export default {
  data() {
    return {
      show: false,
      columns,
      queryFormData: {
        orderByColumn: "",
        isAsc: "",
        resourcebm: "",
        resourcemc: "",
        keyword: "",
      },
      FormData: {
        // 类编码
        lbm: null,
        // 项编码
        xbm: null,
        // 目编码
        mbm: null,
        // 资源短编码
        rbm: null,
        // 资源状态
        status: null,
        // 管理员姓名
        username: "黄石管理员",
        // 管理员id
        userid: 1,
        // 资源名称
        resourcemc: null,
        // 部门名称
        deptname: null,
        // 部门id
        deptid: null,
        // 目录分类编号
        configrationid: null,
        // 资源编码
        resourcebm: null,
        // 资源标签关键词
        keyword: null,
        //资源分类
        resourcefl: null,
        //资源类型
        resourcelx: null,
        // 资源数据源ID
        resourcesjyid: null,
        // 关系型数据库schema名
        resourceuser: null,
        // 资源数据对象类型
        resourcesjdxlx: null,
        // 资源数据对象类型
        resourcesjdx: null,
        // 资源数据对象描述
        resourcesjms: null,
        // 资源元数据对象编号
        resourcesjid: null,
        // 资源文件类型
        resourcefiletype: null,
        // 资源文件大小
        resourcefilesize: null,
        // b49fca03a66711eb81120242ac110002
        gxsjid: "",
        //
        bigdataResourcelx: "",
        //
        filename: "",
        bigsjid: "",
        // 行政区划
        xzqh: null,
        // 服务类型
        fwlx: null,
        // 坐标系
        zbx: null,
        // 参考类型
        cklx: null,
        // 比例
        bl: null,
        // 分辨率
        fbl: null,
        // 服务地址
        fwdz: null,
        // 空间范围
        kjfw: null,
        // 获取时间
        kqsj: null,
        // 注册时间
        regdate: null,
        // 共享方式
        sharetype: null,
        // 共享范围
        sharescope: null,
        // 更新频率
        gxzq: null,
        //
        depts: null,
      },
      panelList: [],
      rules: {
        catalogmc: [
          { required: true, message: "请输入目录名称", trigger: "blur" },
        ],
      },
      pagination: {
        current: 1,
        pageSize: 10,
        total: 0,
      },
      verify: true,
      visible: false,
      DataList: [],
      FwlxList: [],
      blxList: [],
      cklxList: [],
      ZbxList: [],
      BlList: [],
      ZytgList: [],
      GxlxList: [],
      GxfwList: [],
      GxzqList: [],
      FblList: [],
      catalogTree: [],
      administrativeTree: [],
      edit: false,
      showEdit: false,
      EditObj: {},
    };
  },
  watch: {
    visible(val, oldval) {
      if (val == false) this.Reset("FormData");
    },
  },
  created() {
    API.getUrlDataApi("/system/dict/data/getDictItems/t_jbxx_fwlx").then(
      (res) => {
        this.FwlxList = res.data;
      }
    );
    API.getUrlDataApi("/system/dict/data/getDictItems/t_jbxx_bl").then(
      (res) => {
        this.BlList = res.data;
      }
    );
    API.getUrlDataApi("/system/dict/data/getDictItems/t_jbxx_zbx").then(
      (res) => {
        this.ZbxList = res.data;
      }
    );
    API.getUrlDataApi("/system/dict/data/getDictItems/t_jbxx_cklx").then(
      (res) => {
        this.CklxList = res.data;
      }
    );
    API.getUrlDataApi("/system/dict/data/getDictItems/t_jbxx_fbl").then(
      (res) => {
        this.FblList = res.data;
      }
    );
    API.getUrlDataApi(
      "/system/dict/data/getDictItems/t_catalog_jbxxb_sharetype"
    ).then((res) => {
      this.GxlxList = res.data;
    });
    API.getUrlDataApi(
      "/system/dict/data/getDictItems/t_catalog_jbxxb_sharescope"
    ).then((res) => {
      this.GxfwList = res.data;
    });
    API.getUrlDataApi(
      "/system/dict/data/getDictItems/t_catalog_jbxxb_gxzq"
    ).then((res) => {
      this.GxzqList = res.data;
    });
    API.getUrlDataApi("/system/dict/data/getDictItems/t_jbxx_dept").then(
      (res) => {
        this.ZytgList = res.data;
      }
    );
    API.postUrlDataApi("/catalog/configration/list", {
      catalogbm: "",
      catalogmc: "",
      cataloglx: "",
      configtype: "",
    }).then((res) => {
      this.panelList = res;
    });
  },
  mounted() {
    this.Search();
  },
  methods: {
    send() {
      API.postUrlDataApi("/resource/jbxxb/add", this.FormData).then((res) => {
        if (res.code == 0) {
          this.Search();
          message.success(`${res.msg}`);
        } else {
          message.error(`${res.msg}`);
        }
        this.Reset("FormData");
        this.FormData.userid = 1;
        this.show = false;
      });
    },
    sendEdit(item) {
      API.postUrlDataApi("/resource/jbxxb/edit", {
        id: item.id,
        lbm: item.lbm,
        xbm: item.xbm,
        rbm: item.rbm,
        resourcemc: item.resourcemc,
        resourcesjdx: item.resourcesjdx,
        resourcebm: item.resourcebm,
        resourcefl: item.resourcefl,
        resourcelx: item.resourcelx,
        xzqh: item.xzqh,
        fwlx: item.fwlx,
        fwdz: item.fwdz,
        zbx: item.zbx,
        bl: item.bl,
        fbl: item.fbl,
        kjfw: item.kjfw,
        kqsj: item.kqsj,
        regdate: item.regdate,
        deptname: item.deptname,
        deptid: item.deptid,
        gxzq: item.gxzq,
        datatotalnum: item.datatotalnum,
        visitcount: item.visitcount,
        keyword: item.keyword,
      }).then((res) => {
        if (res.code == 0) {
          this.Search();
          message.success(`${res.msg}`);
        } else {
          message.error(`${res.msg}`);
        }
        this.showEdit = false;
      });
    },
    handleTableChange(p) {
      API.postUrlDataApi("/resource/jbxxb/list", {
        pageSize: p.pageSize,
        pageNum: p.current,
        orderByColumn: this.queryFormData.orderByColumn,
        isAsc: this.queryFormData.isAsc,
        resourcebm: this.queryFormData.resourcebm,
        resourcemc: this.queryFormData.resourcemc,
        keyword: this.queryFormData.keyword,
      }).then((res) => {
        this.pagination.current = p.current;
        this.pagination.total = res.total;
        this.DataList = res.rows;
      });
    },
    // 新增
    AddCatalog() {
      this.show = true;
      API.getUrlDataApi("/catalog/configration/treeData").then((res) => {
        this.catalogTree = buildtree(res, "pId", "id");
        isLeaf(this.catalogTree);
      });
      API.getUrlDataApi("/dm/xzqh/treeData").then((res) => {
        this.administrativeTree = buildtree(res, "pId", "id");
      });
    },
    // 修改
    Rectify(item) {
      API.getUrlDataApi("/catalog/configration/treeData").then((res) => {
        this.catalogTree = buildtree(res, "pId", "id");
        isLeaf(this.catalogTree);
      });
      API.getUrlDataApi("/dm/xzqh/treeData").then((res) => {
        this.administrativeTree = buildtree(res, "pId", "id");
      });
      let Data = JSON.parse(JSON.stringify(item));
      this.EditObj = Data;
      this.showEdit = true;
    },
    // 增/改
    handleOk() {
      let URL = this.edit
        ? "/catalog/configration/edit"
        : "/catalog/configration/add";
      let postData = this.edit
        ? {
            bz: this.FormData.bz,
            cataloglen: this.FormData.cataloglen,
            catalogmc: this.FormData.catalogmc,
            parentid: this.FormData.parentid,
            configtype: 2,
            parentmc: this.FormData.parentmc,
            id: this.FormData.id,
          }
        : {
            bz: this.FormData.bz || "",
            cataloglen: this.FormData.cataloglen || "",
            catalogmc: this.FormData.catalogmc || "",
            parentid: this.FormData.parentid || "",
            configtype: 2,
            parentmc: this.FormData.parentmc || "",
          };
      API.postUrlDataApi(URL, postData).then((res) => {
        if (res.code == 0) {
          this.Search();
          message.success(`${res.msg}`);
        } else {
          message.error(`${res.msg}`);
        }
      });
      this.edit = false;
      this.visible = false;
    },
    // 删除
    onDel(row) {
      API.postUrlDataApi(`/resource/jbxxb/remove`, {
        ids: row.id,
      }).then((res) => {
        if (res.code == 0) {
          message.success(`${res.msg}`);
        } else {
          message.error(`${res.msg}`);
        }
        this.Search();
      });
    },
    // 搜索
    Search() {
      API.postUrlDataApi("/resource/jbxxb/list", {
        pageSize: this.pagination.pageSize,
        pageNum: this.pagination.current,
        orderByColumn: this.queryFormData.orderByColumn,
        isAsc: this.queryFormData.isAsc,
        resourcebm: this.queryFormData.resourcebm,
        resourcemc: this.queryFormData.resourcemc,
        keyword: this.queryFormData.keyword,
      }).then((res) => {
        res.rows.forEach((element) => {
          // 资源目录
          let catalogName = this.panelList.filter(
            (c) => c.id == element.configrationid
          );
          if (catalogName.length > 0) {
            element.catalogName = catalogName[0].catalogmc;
          } else {
            element.catalogName = "";
          }
          // 共享类型
          let sharetypeName = this.GxlxList.filter(
            (c) => c.dictValue == element.sharetype
          );
          if (sharetypeName.length > 0) {
            element.sharetypeName = sharetypeName[0].dictLabel;
          } else {
            element.sharetypeName = "";
          }
          // 服务类型
          let fwlxName = this.FwlxList.filter(
            (c) => c.dictValue == element.fwlx
          );
          if (fwlxName.length > 0) {
            element.fwlxName = fwlxName[0].dictLabel;
          } else {
            element.fwlxName = "";
          }
          //  比例
          let blName = this.BlList.filter((c) => c.dictValue == element.bl);
          if (blName.length > 0) {
            element.blName = blName[0].dictLabel;
          } else {
            element.blName = "";
          }
          //  分辨率
          let fblName = this.FblList.filter((c) => c.dictValue == element.fbl);
          if (fblName.length > 0) {
            element.fblName = fblName[0].dictLabel;
          } else {
            element.fblName = "";
          }
          //  坐标系
          let zbxName = this.ZbxList.filter((c) => c.dictValue == element.zbx);
          if (zbxName.length > 0) {
            element.zbxName = zbxName[0].dictLabel;
          } else {
            element.zbxName = "";
          }
          //   参考类型
          let cklxName = this.CklxList.filter(
            (c) => c.dictValue == element.cklx
          );
          if (cklxName.length > 0) {
            element.cklxName = cklxName[0].dictLabel;
          } else {
            element.cklxName = "";
          }
          //  更新周期
          let gxzqName = this.GxzqList.filter(
            (c) => c.dictValue == element.gxzq
          );
          if (gxzqName.length > 0) {
            element.gxzqName = gxzqName[0].dictLabel;
          } else {
            element.gxzqName = "";
          }
        });
        this.pagination.total = res.total;
        this.DataList = res.rows;
      });
    },
    // 重置
    quxaio(name) {
      this[name] = false;
      this.Reset("FormData");
      this.FormData.userid = 1;
    },
    DateChange(date, val) {
      this.FormData.regdate = val;
    },
    editDateChange(date, val) {
      this.EditObj.regdate = val;
    },
    // 重置
    Reset(name) {
      Object.keys(this[name]).forEach((key) => {
        this[name][key] = "";
      });
      this.Search();
    },
    // 资源提供方
    deptidChange(val, op) {
      this.FormData.deptid = val;
      this.FormData.deptname = op.children[0].children;
    },

    // 目录资源
    treeChange(val, lable, extra) {
      API.getUrlDataApi("resource/jbxxb/operaResourceBm", {
        catalogid: val,
      }).then((res) => {
        this.FormData.xbm = res.xbm;
        this.FormData.rbm = res.rbm;
        this.FormData.lbm = res.lbm;
        this.FormData.resourcebm = `${res.lbm}${res.xbm}/${res.rbm}`;
      });
      if (val === null) {
        return;
      }
      this.FormData.configrationid = val;
    },
    // 行政区划
    administrativeChange(val, lable, extra) {
      if (val === null) {
        return;
      }
      this.FormData.xzqh = val;
    },
  },
};
</script>
<style lang="less" scoped>
.new-form-box {
  position: absolute;
  box-sizing: border-box;
  width: 100%;
  height: calc(100% - 42px);
  background-color: #fff;
  z-index: 99;
  border: 1px solid #e7eaec;
  display: none;

  .title-box {
    padding-left: 20px;
    background: #f8f8f8;
    color: #333;
    font-size: 14px;
    height: 42px;
    line-height: 42px;
    border: none;
    font-weight: bold;
    border-bottom: 1px solid #e7eaec;
    display: flex;
    align-items: center;
    justify-content: space-between;
    span {
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      width: 42px;
      height: 42px;
    }
    span:hover {
      background-color: rgb(221, 221, 221);
    }
  }
  .content-box {
    height: calc(100% - 42px);
    overflow: auto;
    box-sizing: border-box;
    width: 100%;
    padding: 20px 40px;
    .w-row {
      width: 100%;
      display: flex;
      justify-content: space-around;
    }
  }
  .footer-box {
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    height: 56px;
    background: #f8f8f8;
    border-top: 1px solid rgb(233, 233, 233);
  }
}
.md-show {
  display: block;
}

.manage-wrap {
  position: relative;
  width: 100%;
  height: calc(100vh - 148px);
  display: flex;
  .manage-box {
    box-sizing: border-box;
    height: calc(100vh - 148px);
    overflow: auto;
    width: 100%;
    scrollbar-color: #5175f6;
    &::-webkit-scrollbar {
      width: 3px;
      height: 1px;
    }
    &::-webkit-scrollbar-thumb {
      border-radius: 3px;
      background: #5175f6;
    }
  }
}
h4 {
  font-weight: 600;
}
</style>

